package com.nmc.service.dao.impl;


import org.hibernate.SessionFactory;

import com.nmc.service.dao.DeathDao;
import com.nmc.service.model.Death;

/**
 * This class interacts with Spring's HibernateTemplate to save/delete and
 * retrieve Death objects.
 *
*/
public class DeathDaoImpl extends GenericDaoImpl<Death, String> implements DeathDao {

    public DeathDaoImpl(Class<Death> persistentClass,
			SessionFactory sessionFactory) {
		super(persistentClass, sessionFactory);
		// TODO Auto-generated constructor stub
	} 

	public DeathDaoImpl(Class<Death> persistentClass) {
		super(persistentClass);
		// TODO Auto-generated constructor stub
	}

	/**
     * Constructor that sets the entity to User.class.
     */
    public DeathDaoImpl() {
        super(Death.class);
    }

   
    /**
     * {@inheritDoc}
     */
    public Death saveDeath(Death death) {
        if (log.isDebugEnabled()) {
            log.debug("death's id: " + death.getId());
        }
        getHibernateTemplate().saveOrUpdate(death);
        // necessary to throw a DataIntegrityViolation and catch it in UserManager
        getHibernateTemplate().flush();
        return death;
    }

    
}
